package com.yue.event;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/11/29<br/>
 *
 * @author QiuYang
 */
public class ValueSource {
    private int v;
    ValueChangeListenerRegister register = new ValueChangeListenerRegister();

    public ValueSource(int v){
        this.v = v;
    }

    public int getV() {
        return v;
    }

    public void setV(int v) {
        this.v = v;

        ChangeEvent event = new ValueChangeEvent(this, v);
        ValueChangeListener listener = new ValueChangeListener();
        register.register(listener);
        register.fireEvent(event);
    }

    @Override
    public String toString() {
        return v+"";
    }

    public static void main(String[] args) {
        ValueSource source = new ValueSource(10);
        source.setV(100);
    }
}
